package cn.edu.scau.cmi.chenjiale.composite.clarity;

import java.util.ArrayList;
import java.util.List;

/**
 * 透明形式的组织模式的组合类
 * 
 * @author chen
 * @date 2019/04/16
 *
 */
public class ClarityOrganizationComposite extends ClarityOrganization {
	private List<ClarityOrganization> childList = new ArrayList<ClarityOrganization>();

	public ClarityOrganizationComposite() {

	}

	public ClarityOrganizationComposite(String name) {
		super(name);
	}

	@Override
	public String display() {
		StringBuilder builder = new StringBuilder();
		builder.append("组织名称：" + name + "\n");
		for (ClarityOrganization organization : childList) {
			String childName = organization.display();
			builder.append("  "+childName + "\n");
		}
		return builder.toString();
	}

	@Override
	public boolean addChild(ClarityOrganization organization) {
		this.childList.add(organization);
		return true;
	}

	@Override
	public boolean removeChild(ClarityOrganization organization) {
		this.childList.add(organization);
		return true;
	}

}
